package mdb

import (
	"gopkg.in/mgo.v2/bson"
)

type QueryOption struct {
	db         string
	collection string
	selector   bson.M
	updateM    bson.M
	skip       int
	limit      int
	sort       []string
}

func (query *QueryOption) WithDb(db string) *QueryOption {
	query.db = db
	return query
}

func (query *QueryOption) WithCollection(collection string) *QueryOption {
	query.collection = collection
	return query
}

func (query *QueryOption) WithSelector(selector bson.M) *QueryOption {
	query.selector = selector
	return query
}

func (query *QueryOption) WithUpdateM(updateM bson.M) *QueryOption {
	query.updateM = updateM
	return query
}

func (query *QueryOption) WithSkip(skip int) *QueryOption {
	query.skip = skip
	return query
}

func (query *QueryOption) WithLimit(limit int) *QueryOption {
	query.limit = limit
	return query
}

func (query *QueryOption) WithSort(sort string) *QueryOption {
	if query.sort == nil {
		query.sort = make([]string, 0)
	}
	query.sort = append(query.sort, sort)
	return query
}
